# -*- coding: utf-8 -*-
import os.path
from cbsettings import DjangoDefaults, switcher


_ROOT = os.path.abspath(os.path.dirname(__file__))

class Base(DjangoDefaults):


    DEBUG = TEMPLATE_DEBUG = False

    # Задаются в local_settings
    #
    SECRET_KEY = ""

    DATABASES = {
        'default': {
            'ENGINE': 'django.db.backends.sqlite3',
            'NAME': 'var/data.db',
        }
    }

    FIXTURE_DIRS = (

    )

    TIME_ZONE = 'Europe/Moscow'

    LANGUAGE_CODE = 'ru'

    gettext = lambda s: s

    LANGUAGES = (
        ('ru', gettext('Russian')),
        ('en', gettext('English')),
    )

    MODELTRANSLATION_DEFAULT_LANGUAGE = 'ru'
    MODELTRANSLATION_FALLBACK_LANGUAGES = ('ru', 'en')



    LOCALE_PATHS = (
        os.path.join(_ROOT, '../conf/locale/'),
    )



    SITE_ID = 1

    USE_I18N = USE_L10N = True

    MEDIA_ROOT = './var/media'

    MEDIA_URL = '/media/'

    UPLOAD_TO = os.path.join(MEDIA_ROOT)

    STATICFILES_DIRS = (
        ("",os.path.join(_ROOT, 'core/static/')),
    )

    STATIC_URL = '/static/'
    STATIC_ROOT = '/static/'

    ACCOUNT_ACTIVATION_DAYS = 2

    EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'

    TEMPLATE_LOADERS = (
        'django.template.loaders.filesystem.Loader',
        'django.template.loaders.app_directories.Loader',
        'django.template.loaders.eggs.Loader',
    )

    MIDDLEWARE_CLASSES = (
        'django.middleware.common.CommonMiddleware',
        'django.contrib.sessions.middleware.SessionMiddleware',
        'django.middleware.csrf.CsrfViewMiddleware',
        'django.middleware.locale.LocaleMiddleware',
        'django.contrib.auth.middleware.AuthenticationMiddleware',
        'django.contrib.messages.middleware.MessageMiddleware',
    )

    TEMPLATE_CONTEXT_PROCESSORS = (
        'django.contrib.auth.context_processors.auth',
        'django.core.context_processors.debug',
        'django.core.context_processors.i18n',
        'django.core.context_processors.media',
        'django.core.context_processors.static',
        'django.contrib.messages.context_processors.messages',
        'django.core.context_processors.request',
        'sitegear.structure.context_processors.current_node',
    )

    ROOT_URLCONF = 'sitegear.urls'

    ULOGIN_FIELDS = ['first_name', 'last_name']

    ULOGIN_PROVIDERS = ['vkontakte', 'facebook', 'twitter', 'google', 'yandex']

    CACHES = {
        'default': {
            'BACKEND': 'django.core.cache.backends.dummy.DummyCache',
        }
    }


    TEMPLATE_DIRS = (
        os.path.join(_ROOT, 'templates'),
        os.path.join(_ROOT, 'templates/tpls'),
        
    )

    LOGIN_URL = '/accounts/login'
    LOGOUT_URL = '/accounts/logout'

    INSTALLED_APPS = (
        'django.contrib.auth',
        'django.contrib.contenttypes',
        'django.contrib.sessions',
        'django.contrib.sites',
        'django.contrib.messages',
        'django.contrib.admin',
        'django.contrib.staticfiles',
        'django.contrib.markup',
        'modeltranslation',
        'south',
        'registration',
        'mptt',
        'sorl.thumbnail',
        'django_ulogin',
        'sitegear.core',
        'sitegear.account',
        'sitegear.structure',
        #'iform.intellect.forms',
        #'sitegear.intellect.content',
        'sitegear.intellect.data',
        'sitegear.api',
        'sitegear.structure.global',

    )

    MODELTRANSLATION_TRANSLATION_FILES = (
            'sitegear.structure.translation',
    )


class Dev(Base):
    DEBUG = True
    TEMPLATE_DEBUG = DEBUG
    SECRET_KEY = "sdsadasdasdasdas="
    DATABASES = {
        'default': {
            'ENGINE': 'django.db.backends.sqlite3',
            'NAME': './var/data.db',
        }
    }
    INSTALLED_APPS = Base.INSTALLED_APPS + (
        #'werkzeug_debugger_runserver',
    )

    from log_settings import DEBUG_LOGGING
    LOGGING = DEBUG_LOGGING


class Prod(Base):
    SECRET_KEY = "asdsad30e23093uiojrlkwkewe="
    DEBUG = False
    TEMPLATE_DEBUG = DEBUG
    INSTALLED_APPS = Base.INSTALLED_APPS + (
        'gunicorn',
        )

import sys
pathname, scriptname =  os.path.split(sys.argv[0])
_PATH = os.path.abspath(pathname)

switcher.register(Dev, lambda: os.path.exists(  os.path.join(_PATH, ".dev" )))
switcher.register(Prod, lambda: os.path.exists(  os.path.join(_PATH, ".prod" )))
switcher.register(Dev, lambda: not (os.path.exists(  os.path.join(_PATH, ".dev" ) or os.path.exists(  os.path.join(_PATH, ".dev" ) )   )) )
switcher.register(Prod, hostnames=['rtackit.ru'])
